package com.dt.platform.generator.module.oa;

import com.dt.platform.constants.db.OaTables;
import com.dt.platform.constants.enums.oa.ProjectTaskRcdCatalogEnum;
import com.dt.platform.domain.oa.Project;
import com.dt.platform.domain.oa.ProjectTask;
import com.dt.platform.domain.oa.ProjectTaskRcd;
import com.dt.platform.domain.oa.meta.ProjectTaskMeta;
import com.dt.platform.domain.oa.meta.ProjectTaskRcdMeta;
import com.dt.platform.generator.config.Config;
import com.dt.platform.oa.page.ProjectTaskRcdPageController;
import com.dt.platform.proxy.oa.ProjectTaskRcdServiceProxy;
import com.github.foxnic.generator.builder.view.config.DatePickerType;
import com.github.foxnic.generator.config.WriteMode;
import org.github.foxnic.web.domain.hrm.Employee;
import org.github.foxnic.web.domain.system.DictItem;
import org.github.foxnic.web.domain.system.meta.DictItemMeta;
import org.github.foxnic.web.proxy.system.DictItemServiceProxy;

public class AProjectTaskRcdGtr extends BaseCodeGenerator {


    public AProjectTaskRcdGtr() {
        super(OaTables.OA_PROJECT_TASK_RCD.$TABLE,"705020984087805957");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.ID).basic().hidden(true);
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.CT).search().fuzzySearch();
        cfg.getPoClassFile().addSimpleProperty(Employee.class,"owner","owner","owner");
        cfg.getPoClassFile().addSimpleProperty(DictItem.class,"workTypeDict","workTypeDict","workTypeDict");

        cfg.getPoClassFile().addSimpleProperty(Project.class,"project","project","project");
        cfg.getPoClassFile().addSimpleProperty(ProjectTask.class,"task","task","task");

        cfg.getPoClassFile().addSimpleProperty(String.class,"selectRange","selectRange","selectRange");


        cfg.getPoClassFile().addSimpleProperty(String.class,"tabStatus","tabStatus","tabStatus");


        cfg.view().field(ProjectTaskRcdMeta.TAB_STATUS).table().disable(true);


        cfg.view().search().inputLayout(
                new Object[]{
                        OaTables.OA_PROJECT_TASK_RCD.STATUS,
                        OaTables.OA_PROJECT_TASK_RCD.S_TIME,
                }
        );

        cfg.view().search().disable();

        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.OWNER_ID).table().fillBy("owner","name");
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.OWNER_ID).form()
                .button().chooseEmployee(true);

        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.UPDATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.CREATE_BY).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.CREATE_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.STATUS).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.E_TIME).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.FILE_ID).table().disable(true);
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.WORK_CATALOG).table().disable(true);


        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.S_TIME).form().validate().required().form().dateInput().defaultNow().format("yyyy-MM-dd HH:mm:ss").type(DatePickerType.datetime).search().range();
        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.E_TIME).form().validate().required().form().dateInput().defaultNow().format("yyyy-MM-dd HH:mm:ss").type(DatePickerType.datetime).search().range();

        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.CT).form().validate().required().form().textArea().height(60);

        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.NOTES).form().textArea().height(120);


        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);



        cfg.view().formWindow().bottomSpace(100);

        cfg.view().formWindow().width(Config.baseFormWidth);

        cfg.view().form().addGroup(null,
                new Object[] {
                        OaTables.OA_PROJECT_TASK_RCD.S_TIME,
                        OaTables.OA_PROJECT_TASK_RCD.WORK_TYPE,
//                        OaTables.OA_PROJECT_TASK_RCD.WORK_CATALOG,
                },
                new Object[] {
                        OaTables.OA_PROJECT_TASK_RCD.E_TIME,

                }
        );
        cfg.view().form().addGroup(null,
                new Object[] {

                        OaTables.OA_PROJECT_TASK_RCD.CT,
                        OaTables.OA_PROJECT_TASK_RCD.NOTES
                }
        );

        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.FILE_ID).form().upload().maxFileCount(6);

        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.WORK_CATALOG).form()
                .radioBox().enumType(ProjectTaskRcdCatalogEnum.class).defaultIndex(0);

        cfg.view().field(OaTables.OA_PROJECT_TASK_RCD.WORK_TYPE)
                .form().validate().required().form().selectBox().queryApi(DictItemServiceProxy.QUERY_PAGED_LIST+"?dictCode=oa_project_work_type")
                .defaultIndex(1).paging(true).filter(true).toolbar(true)
                .valueField(DictItemMeta.CODE).
                textField(DictItemMeta.LABEL).
                fillWith(ProjectTaskRcdMeta.WORK_TYPE_DICT).muliti(false);

        cfg.view().list().columnLayout(OaTables.OA_PROJECT_TASK_RCD.WORK_CATALOG,OaTables.OA_PROJECT_TASK_RCD.S_TIME,OaTables.OA_PROJECT_TASK_RCD.WORK_TIME,OaTables.OA_PROJECT_TASK_RCD.CT,OaTables.OA_PROJECT_TASK_RCD.WORK_TYPE,OaTables.OA_PROJECT_TASK_RCD.OWNER_ID);
        cfg.view().list().disableBatchDelete();
        cfg.view().list().addJsVariable("PROJECT_ID","[[${projectId}]]","projectId");
        cfg.view().list().addJsVariable("TASK_ID","[[${taskId}]]","taskId");

        cfg.view().form().addJsVariable("TASK_ID","[[${taskId}]]","taskId");

        cfg.view().list().addJsVariable("PAGE_TYPE","[[${pageType}]]","pageType");
        cfg.view().list().addJsVariable("DATA_RANGE","[[${dataRange}]]","dataRange");

        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.IGNORE) //服务与接口
                .setControllerAndAgent(WriteMode.IGNORE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页
        //列表HTML页
        //生成代码


        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        AProjectTaskRcdGtr g=new AProjectTaskRcdGtr();
        //生成代码
        g.generateCode();

        //移除之前生成的菜单，视情况执行
//        g.removeByBatchId("471622036347682816");
        //生成菜单
     //  g.generateMenu(ProjectTaskRcdServiceProxy.class, ProjectTaskRcdPageController.class);
    }

}
